package com.rgp.apidriver.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.rgp.apidriver.feign.ServiceSsePushClient;
import com.rgp.apidriver.service.PayOffOrderService;
import com.rgp.internalcommon.dto.LaunchOrderPayOffDto;
import com.rgp.internalcommon.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author nhp
 * @version 1.0
 * @description TODO
 * @date 2024-04-26 19:57
 */
@Service
public class PayOffOrderServiceImpl implements PayOffOrderService {

    @Autowired
    private ServiceSsePushClient serviceSsePushClient;

    @Override
    public ResponseResult launchPayOffOrderByDriver(LaunchOrderPayOffDto launchOrderPayOffDto) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("orderId",launchOrderPayOffDto.getOrderId());
        jsonObject.put("price",launchOrderPayOffDto.getPrice());
        jsonObject.put("passengerId",launchOrderPayOffDto.getPassengerId());
        jsonObject.put("driverId",launchOrderPayOffDto.getDriverId());
        String message = jsonObject.toString();
        serviceSsePushClient.push(launchOrderPayOffDto.getPassengerId() + "",message);
        return ResponseResult.success();
    }
}
